package com.cskaoyan.controller;

import com.cskaoyan.bean.BaseRespVo;
import com.cskaoyan.bean.bo.KeywordBO;
import com.cskaoyan.bean.param.BaseParam;
import com.cskaoyan.bean.po.KeywordPO;
import com.cskaoyan.bean.po.KeywordUpdatePO;
import com.cskaoyan.bean.vo.KeywordListVO;
import com.cskaoyan.bean.vo.KeywordVO;
import com.cskaoyan.service.KeywordService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/***
 * zx
 * 关键字
 */
@RestController
@RequestMapping("admin/keyword")
public class KeywordController {

    @Autowired
    KeywordService keywordService;

    @RequestMapping("list")
    public BaseRespVo list(BaseParam baseParam,String keyword,String url){
        KeywordVO keywordListVO = keywordService.queryKeyword(baseParam,keyword,url);
        return BaseRespVo.ok(keywordListVO);
    }

    @RequestMapping("create")
    public BaseRespVo create(@RequestBody KeywordBO keywordBO){
        KeywordPO keywordPO = keywordService.createNewKeyword(keywordBO);
        return BaseRespVo.ok(keywordPO);
    }

    @RequestMapping("update")
    public BaseRespVo update(@RequestBody KeywordBO keywordBO){
        KeywordUpdatePO keywordPO = keywordService.updateKeyword(keywordBO);
        return BaseRespVo.ok(keywordPO);
    }

    @RequestMapping("delete")
    public BaseRespVo delete(@RequestBody KeywordUpdatePO keywordUpdatePO){
        keywordService.delete(keywordUpdatePO);
        return BaseRespVo.ok(null);

    }
}
